using Ch13CardLib.enums;
using System;
using System.ComponentModel;

namespace KarliCardsGui.ViewModels
{
    public class CardViewModel : INotifyPropertyChanged
    {
        private bool isFaceUp;
        private double xPosition;
        private double yPosition;
        private int zIndex;
        private bool isEmpty;
        private bool isClickable;

        public Suit Suit { get; set; }
        public Rank Rank { get; set; }

        public bool IsEmpty
        {
            get => isEmpty;
            set
            {
                if (isEmpty != value)
                {
                    isEmpty = value;
                    OnPropertyChanged(nameof(IsEmpty));
                }
            }
        }

        public bool IsFaceUp
        {
            get => isFaceUp;
            set
            {
                if (isFaceUp != value)
                {
                    isFaceUp = value;
                    OnPropertyChanged(nameof(IsFaceUp));
                }
            }
        }

        public double XPosition
        {
            get => xPosition;
            set
            {
                xPosition = value;
                OnPropertyChanged(nameof(XPosition));
            }
        }

        public double YPosition
        {
            get => yPosition;
            set
            {
                yPosition = value;
                OnPropertyChanged(nameof(YPosition));
            }
        }

        public int ZIndex
        {
            get => zIndex;
            set
            {
                zIndex = value;
                OnPropertyChanged(nameof(ZIndex));
            }
        }

        public bool IsClickable
        {
            get => isClickable;
            set
            {
                if (isClickable != value)
                {
                    isClickable = value;
                    OnPropertyChanged(nameof(IsClickable));
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        public CardViewModel()
        {
            IsEmpty = false;  // 默认不为空
        }
    }
} 